﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace STX.Web.Framework.Controllers
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited=true, AllowMultiple=true)]
    public class AdminAuthorizeAttribute : AuthorizeAttribute
    {
        
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext == null)
                throw new Exception("filterContext is null");
            base.OnAuthorization(filterContext);
        }

        //protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        //{
        //    if(httpContext==null)
        //        throw new Exception("httpContext is null");
        //    var AdminUser = AdminContext.CurrentUser;
        //    if (AdminUser == null)
        //    {
        //        return false;
        //    }
        //    return true;
        //}

        //protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        //{
        //    if (filterContext == null)
        //        throw new Exception("filterContext is null");
        //    //filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new dic
        //    filterContext.Result = new ContentResult() { Content = " 未授权，不能访问" };
        //}
    }
}
